from django.db import models

from apps.aiauth.models import Users
from apps.setup.models import Experts


class Applyjob(models.Model):
    applyjob_id = models.BigAutoField(primary_key=True, db_column='applyjob_id')
    user = models.ForeignKey(Users, models.DO_NOTHING, blank=True, null=True, db_column='user_id')
    job_name = models.CharField(max_length=255, blank=True, null=True)
    apply_time = models.DateTimeField(blank=True, null=True)
    apply_channel = models.CharField(max_length=255, blank=True, null=True)
    offer = models.BooleanField(blank=True, null=True)
    summary = models.CharField(max_length=255, blank=True, null=True)
    company = models.CharField(max_length=50, blank=True, null=True)
    company_contact = models.CharField(max_length=100, blank=True, null=True)
    create_time = models.DateTimeField(blank=True, null=True)
    job_type = models.CharField(max_length=255, blank=True, null=True)

    class Meta:
        db_table = 'applyjob'
        verbose_name_plural = '求职管理表'


class CommentsJob(models.Model):
    comments_id = models.BigAutoField(primary_key=True, db_column='comments_id')
    applyjob = models.ForeignKey(Applyjob, models.DO_NOTHING, related_name='commentsjob',
                                 blank=True, null=True, db_column='applyjob_id')
    user = models.ForeignKey(Users, models.DO_NOTHING, blank=True, null=True, db_column='user_id')
    experts = models.ForeignKey(Experts, models.DO_NOTHING, blank=True, null=True, db_column='experts_id')
    parent_id = models.IntegerField(blank=True, null=True, db_column='parent_id')
    content = models.TextField(blank=True, null=True, db_column='content')
    content_json = models.TextField(blank=True, null=True, db_column='content_json')
    is_author = models.IntegerField(blank=True, null=True, db_column='is_author')
    create_time = models.DateTimeField(db_column='create_time')
    update_time = models.DateTimeField(blank=True, null=True, db_column='update_time')
    status = models.IntegerField(blank=True, null=True, db_column='status')

    class Meta:
        db_table = 'comments_job'
        verbose_name_plural = '求职管理评论表'


class Interviews(models.Model):
    interviews_id = models.BigAutoField(primary_key=True, db_column='interviews_id')
    applyjob = models.ForeignKey(Applyjob, models.DO_NOTHING, related_name='interviews', blank=True, null=True,
                                 db_column='applyjob_id')
    time = models.DateTimeField(blank=True, null=True)
    content = models.CharField(max_length=255, blank=True, null=True)
    create_time = models.DateTimeField()

    # def __str__(self):
    # return "{time : %s, content : %s, create_time : %s}" % (self.time, self.content, self.create_time)

    class Meta:
        db_table = 'interviews'
        verbose_name_plural = '面试记录表'
